package org.hu.vhr.service;

import org.hu.vhr.mapper.PositionMapper;
import org.hu.vhr.model.Position;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class PositionService {
    @Autowired
    PositionMapper positionMapper;

    /**
     * 查询全部职位
     * @return List<Position>
     */
    public List<Position> getAllPositions() {
        return positionMapper.getAllPositions();
    }

    /**
     * 增加职位
     * @param position
     * @return Integer
     */
    public Integer insertPosition(Position position) {
        position.setEnabled(true);
        position.setCreateDate(new Date());
        return positionMapper.insertSelective(position);
    }

    /**
     * 更新职位信息
     * @param position
     * @return Integer
     */
    public Integer updatePosition(Position position) {
        position.setCreateDate(new Date());
        return positionMapper.updateByPrimaryKey(position);
    }

    /**
     * 删除职位
     * @param id
     * @return Integer
     */
    public Integer deletePosition(Integer id) {
        return positionMapper.deleteByPrimaryKey(id);
    }

    /**
     * 批量删除职位
     * @param ids
     * @return
     */
    public Integer deletePositions(Integer[] ids) {
        return positionMapper.deletePositions(ids);
    }
}
